package com.example.fisttestproject.controller;

import com.example.fisttestproject.dao.UserDao;
import com.example.fisttestproject.database.AppDatabase;
import com.example.fisttestproject.entity.User;
import com.yanzhenjie.andserver.annotation.GetMapping;
import com.yanzhenjie.andserver.annotation.PostMapping;
import com.yanzhenjie.andserver.annotation.RequestMapping;
import com.yanzhenjie.andserver.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(path = "/user")
public class UserContoller {
    UserDao userDao = AppDatabase.getDatabase(null).userDao();


    @GetMapping(path = "/getAll")
    public List<User> info() {
        List<User> all = userDao.getAll();
        return all;
    }

    @PostMapping(path = "/add")
    public boolean add() {
       userDao.insertAll();
        return true;
    }
}
